﻿<Window x:Class="DbDoc.PowerDoc.Views.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:BO="clr-namespace:DbDoc.BusinessObjects;assembly=DbDoc.BusinessObjects"
        Title="Power Documentation for Databases" Height="800" Width="800" Icon="/PowerDoc;component/dbdoc.ico">
    <Window.Resources>

    </Window.Resources>
    <DockPanel>
        <Menu  DockPanel.Dock="Top" IsMainMenu="True">
            <MenuItem Header="_File" >
                <MenuItem Header="_Synchronize"  Command="{Binding SynchronizeCommand}"  IsEnabled="{Binding EnableSynchronizeButton}" />
                <MenuItem Header="_Refresh"  Command="{Binding RefreshCommand}"  />
                <MenuItem Header="S_ettings" Command="{Binding SettingsCommand}" />
                <MenuItem Header="_Quit" Command="{Binding ExitCommand}" />
            </MenuItem>
            <MenuItem Header="_Help"></MenuItem>
        </Menu>
        <TextBlock  DockPanel.Dock="Top" Margin="0,5" Text="  Power Doc"  Style="{StaticResource HeaderText}" Grid.ColumnSpan="2">
        </TextBlock>
        
        <StatusBar DockPanel.Dock="Bottom" Height="26" >
            <StatusBar.ItemsPanel >
                <ItemsPanelTemplate>
                    <Grid>
                        <Grid.RowDefinitions >
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions >

                            <ColumnDefinition Width="500*" />
                            <ColumnDefinition Width="250" />
                            <ColumnDefinition Width="250" />
                        </Grid.ColumnDefinitions>
                    </Grid>
                </ItemsPanelTemplate>
            </StatusBar.ItemsPanel>
            <StatusBarItem  Grid.Column="0"  >
                <StackPanel Orientation="Horizontal">
                <Ellipse Width="15" Height="15" Fill="Green" Stroke="Black" StrokeThickness="1"/>
                    <TextBlock Text="  "/>
                <TextBlock Text="{Binding StatusMessage}"/>
                </StackPanel>
            </StatusBarItem>
            <StatusBarItem   Grid.Column="1">
                <StatusBarItem.Content>
                    <StackPanel Orientation="Horizontal" >
                        <TextBlock Text="Source: " FontWeight="Bold" ToolTip="The source (databases) which you want to document."/>
                        <TextBlock Text="{Binding SourceStoreageName}"/>
                    </StackPanel>
                </StatusBarItem.Content>
            </StatusBarItem>
            <StatusBarItem  Grid.Column="2">
                <StatusBarItem.Content>
                    <StackPanel Orientation="Horizontal" >
                        <TextBlock Text="Persistence : " FontWeight="Bold" ToolTip="The place where your comments will be stored."/>
                        <TextBlock Text="{Binding PersistenceStoreageName}"/>
                    </StackPanel>
                </StatusBarItem.Content>
            </StatusBarItem>
        </StatusBar>

        <TreeView  Width="250" DockPanel.Dock="Left" ItemsSource="{Binding DatabasesModel}" IsTextSearchEnabled="True"
                    SelectedItemChanged="TreeView_SelectedItemChanged" >
            <TreeView.ItemTemplate>
                <HierarchicalDataTemplate ItemsSource="{Binding Children}">
                    <TextBlock Text="{Binding Name}" />
                </HierarchicalDataTemplate>

            </TreeView.ItemTemplate>


        </TreeView>
        <DockPanel >
            <Grid DockPanel.Dock="Top" Margin="10,0,10,0" >
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="100"/>
                    <ColumnDefinition Width="200*"/>
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="28" />
                    <RowDefinition Height="28" />
                    <RowDefinition Height="56" />
                    <RowDefinition Height="28" />
                    <RowDefinition Height="28*" />
                </Grid.RowDefinitions>
                <TextBlock Text="{Binding Message}" Grid.ColumnSpan="2"></TextBlock>
                <TextBlock Grid.Row="1">Name</TextBlock>
                <TextBox Grid.Row="1" Grid.Column="1" Text ="{Binding SelectedObject.Name}"  Width="200" HorizontalAlignment="Left" IsReadOnly="True" />
                <TextBlock Grid.Row="2">Comment</TextBlock>
                <TextBox Grid.Row="2" Grid.Column="1" Text ="{Binding SelectedObject.UnderlyingDbObject.Comment.Text}" />
                <Button Grid.Row="3" Grid.Column="1" Command="{Binding UpdateSelectedObjectCommand}" Width="75">Update</Button>

                <DataGrid ItemsSource="{Binding SelectedObject.Children}" Name="dgComments"
                          CanUserAddRows="False"
                          CanUserDeleteRows="False" 
                          AutoGenerateColumns="False"
                          Grid.Row="4" Grid.ColumnSpan="3" MouseDoubleClick="DataGrid_MouseDoubleClick">
                    <DataGrid.Columns>
                        <DataGridTextColumn Binding="{Binding Name}" Header="Name" Width="150" IsReadOnly="True"/>
                        <DataGridTextColumn Binding="{Binding UnderlyingDbObject.Comment.Text}" Header="Comments" Width="200*"  />
                        <DataGridTextColumn Binding="{Binding UnderlyingDbObject.Comment.ModifiedBy}" Header="Updated By" Width="100"   IsReadOnly="True"/>
                        <DataGridTextColumn Binding="{Binding UnderlyingDbObject.Comment.ModifiedOn}" Header="Updated On" Width="100"   IsReadOnly="True"/>
                    </DataGrid.Columns>
                </DataGrid>
            </Grid>
        </DockPanel>

    </DockPanel>
</Window>
